package com.etoak.stock.controller;


import com.etoak.stock.pojo.domin.*;
import com.etoak.stock.service.StockService;
import com.etoak.stock.vo.resp.PageResult;
import com.etoak.stock.vo.resp.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/*
* @author:孙有泽
* @data 2024 9/19
* @description 定义股票相关接口处理器
* */
@Api(value = "/api/quot", tags = {"定义股票相关接口处理器 */"})
@RestController
@RequestMapping("/api/quot")
public class StockController {
    @Autowired
    private StockService stockService;
    /*
    * 获得国内大盘最新指数 ok stock-market-index-info
    * */
    @ApiOperation(value = "查询国内大盘指数", notes = "获得国内大盘最新指数 */", httpMethod = "GET")
    @GetMapping("/index/all")
    public R<List<InnerMarketDomain>> getInnerMarketInfo(){
        return stockService.getInnerMarketInfo();
    }

    /*
    *当前日期的最新国内板块数据 ok  stock_block_rt_info
    *
    * */
    @ApiOperation(value = "获取国内的板块数据", notes = "当前日期的最新板块数据 */", httpMethod = "GET")
    @GetMapping("/sector/all")
    public R<List<StockBlockDomain>> getStockBlockInfo(){
        return stockService.getStockBlockInfo();
    }

    /*
    * 分页查询当前日期的最新涨幅数据
    *
    * */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "page", value = ""),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "pageSize", value = "")
    })
    @ApiOperation(value = "分页查询当前日期的最新涨幅数据", notes = "当前日期的最新涨幅数据 */", httpMethod = "GET")
    @GetMapping("/stock/all")
    public R<PageResult<StockUpdownDomain>> getStockUpdownInfo(@RequestParam(value = "page",required = false ,defaultValue ="1")Integer page,
                                                               @RequestParam(value = "pageSize",required = false,defaultValue = "10")Integer pageSize){
        return stockService.getStockUpdownInfo(page,pageSize);
    }
    /*
     * 统计最新股票交易日内每分钟的涨跌停的股票数据
     *
     * */
    @ApiOperation(value = "一天内涨跌值的数量", notes = "一天内涨跌值的数量 */", httpMethod = "GET")
    @GetMapping("/stock/updown/count")
    public R<Map<String,List>> getStockUpdownCount(){
        return stockService.getStockUpdownCount();
    }
    /*
    *
    * 当前前日期的最新涨幅数据前四条数据
    * */
    @ApiOperation(value = "前日期的最新涨幅数据 前四条数据", notes = "前日期的最新涨幅数据 前四条数据 */", httpMethod = "GET")
    @GetMapping("/stock/increase")
    public R<List<StockUpdownDomain>> getStockUpdownLimit(){
        return stockService.getStockUpdownLimit();

    }
    //导出数据
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "page", value = ""),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "pageSize", value = "")
    })
    @ApiOperation(value = "导出数据", notes = "导出数据", httpMethod = "GET")
    @GetMapping("/stock/export")
    public void  exportStockDownInfo(@RequestParam(value = "page",required = false ,defaultValue ="1")Integer page,@RequestParam(value = "pageSize",required = false,defaultValue = "10")Integer pageSize
    ,HttpServletResponse response
    ){
         stockService.exportStockDownInfo(page,pageSize,response);
    }
    //统计大盘T日和T-1日每分钟交易量的数额 stock_market_index_info
    @ApiOperation(value = "统计大盘T日和T-1日每分钟交易量的数额", notes = "统计大盘T日和T-1日每分钟交易量的数额", httpMethod = "GET")
    @GetMapping("/stock/tradeAnt")
    public R<Map<String,List>> getCompareStockTradeAmt(){
        return stockService.getCompareStockTradeAmt();
    }
    /*
    * 统计当前时间下（精确到分钟），A股在各个涨跌区间股票的数量
    *
    * */
    @ApiOperation(value = "统计最新交易时间点股票在各个区间的数量 */", notes = "统计最新交易时间点股票在各个区间的数量 */", httpMethod = "GET")
    @GetMapping("/stock/updown")
    public  R<Map> getIncreaseRangeInfo(){
        return stockService.getIncreaseRangeInfo();
    }
    /*
     * 查询个股的分时行情数据，也就是统计指定股票T日每分钟的交易数据；
     *
     * */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "string", name = "code", value = "", required = true)
    })
    @ApiOperation(value = "查询个股的分时行情数据，也就是统计指定股票T日每分钟的交易数据", notes = "查询个股的分时行情数据，也就是统计指定股票T日每分钟的交易数据", httpMethod = "GET")
    @GetMapping("/stock/screen/time-sharing")
    public R<List<Stock4MinuteDomain>> getStockScreenTimeSharing(@RequestParam(value = "code",required = true)String stockCode){
            return  stockService.getStockScreenTimeSharing(stockCode);
    }
    /*
     * 单个个股日K 数据查询 ，可以根据时间区间查询数日的K线数据；
     *
     * */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "string", name = "code", value = "", required = true)
    })
    @ApiOperation(value = "单个个股日K 数据查询 ，可以根据时间区间查询数日的K线数据； */", notes = "单个个股日K 数据查询 ，可以根据时间区间查询数日的K线数据； */", httpMethod = "GET")
    @GetMapping("/stock/screen/dkline")
    public R<List<Stock4EvrDayDomain>> getStockScreenDkline(@RequestParam(value = "code",required = true)String stockCode){
        return stockService.getStockScreenDkline(stockCode);
    }



}

